<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=7">
    <title>悦定后台管理系统</title>

    <!--判断是否登陆-->
    <script type="text/javascript" src="../../vendor/jquery-2.0.3.min.js"></script>
    <script type="text/javascript" src="../../js/config.js"></script>
    <script type="text/javascript" src="../../js/jquerySession.js"></script>
    <script type="text/javascript">
        if ($.session.get('token') == null) {
            alert("用户未登录！");
            window.location.href = "../../login.html"
        }
    </script>

    <link href="../../css/reset.css" rel="stylesheet" type="text/css">
    <link href="../../css/system.css" rel="stylesheet" type="text/css">
    <link href="../../css/table_form.css" rel="stylesheet" type="text/css">
    <link href="../../css/default.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="../../css/styles1.css" title="styles1" media="screen">
    <link rel="alternate stylesheet" type="text/css" href="../../css/styles2.css" title="styles2" media="screen">
    <link rel="alternate stylesheet" type="text/css" href="../../css/styles3.css" title="styles3" media="screen">
    <link rel="alternate stylesheet" type="text/css" href="../../css/styles4.css" title="styles4" media="screen">
    <script language="javascript" type="text/javascript" src="../../vendor/jquery.min.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/admin_common.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/styleswitch.js"></script>
    <script language="javascript" type="text/javascript" src="../../js/formvalidator.js" charset="UTF-8"></script>
    <script language="javascript" type="text/javascript" src="../../js/formvalidatorregex.js" charset="UTF-8"></script>
    <script type="text/javascript" charset="utf-8" src="../../vendor/kindeditor-all.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../vendor/zh-CN.js"></script>
    <script type="text/javascript" charset="utf-8" src="../../js/currency.js"></script>
    <script type="text/javascript">
        $(function () {
            var editor;
            KindEditor.ready(function (K) {
                editor = K.create('textarea[name="content"]', {
                    uploadJson: baseUrl + '/uploadImage',//上传
                    allowFileManager: false,
                    allowImageUpload: true,
                    fullScreenMode: false,
                    afterBlur: function () {
                        this.sync();
                    }  //数据同步
                });
            });

            function getUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }

            var id = getUrlParam("newId");
            var title = $("#title");
            var content = $("#editor_id");
            var thumbnail = $("#thumbnail");

            $.getJSON(baseUrl + "/articles", {articleId: id}, function (json) {
                if (json.meta.code == 200) {
                    title.empty();
                    content.empty();
                    title.val(json.data.title);
                    thumbnail.attr("src", fileUrl + "/" + json.data.thumbnail);
                    editor.html(json.data.content)
                }
            })


            //图片文件大小控制
            $("#file").change(function () {
                var fileInput = $("#file")[0];
                var byteSize = fileInput.files[0].size;
                if (byteSize > 1024 * 1024) {
                    alert("图片大小超过1M");
                    $("#file").val("");
                }
            })
        })
    </script>
    <script type="text/javascript">window.focus();</script>
</head>
<body>
<div class="subnav">
</div>
<style type="text/css">
    html {
        _overflow-y: scroll
    }
</style>

<form name="myform" id="myform" action="#" method="post">
    <div class="pad-10">
        <div class="col-tab">
            <div id="div_setting_1" class="contentList pad-10">
                <table width="100%" class="table_form ">
                    <tr>
                        <td>
                            新闻标题：<input id="title" type="text"/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            新闻图片：<input id="file" type="file"/>
                        </td>
                    </tr>
                    <br/>
                    <tr>
                        <td>
                            缩略图：<img src="#" alt="无" id="thumbnail" width="150px" height="150px"/>
                        </td>
                    </tr>
                    <br/>
                    <tr>
                        <td>
                            <div class="ke-container ke-container-default" style="width: 650px;"></div>
	                            <textarea id="editor_id" name="content"
                                          style="width: 835px; height: 300px; display: none;">
	                            </textarea>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="bk15"></div>
        </div>
    </div>
    <!--table_form_off-->
</form>
<script language="JavaScript" type="text/javascript">
    window.top.$('#display_center_id').css('display', 'none');
</script>
</body>
</html>